<%= form_for(Settings::Campaign.new,
             url: admin_settings_campaigns_path,
             html: { data: { action: "submit->config#updateConfigurationSettings" } }) do |f| %>
  <details class="crayons-card">
    <summary class="crayons-subtitle-2 p-6">Campaign</summary>
    <div class="p-6 pt-0">
      <fieldset class="grid gap-4">
        <div class="crayons-field">
          <%= admin_config_label :display_name, "Display Name" %>
          <%= admin_config_description Constants::Settings::Campaign.details[:display_name][:description] %>
          <%= f.text_field :display_name,
                           class: "crayons-textfield",
                           value: Settings::Campaign.display_name,
                           placeholder: Constants::Settings::Campaign.details[:display_name][:placeholder] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :hero_html_variant_name, "Campaign hero HTML variant name" %>
          <%= admin_config_description Constants::Settings::Campaign.details[:hero_html_variant_name][:description] %>
          <%= f.text_field :hero_html_variant_name,
                           class: "crayons-textfield",
                           value: Settings::Campaign.hero_html_variant_name,
                           placeholder: Constants::Settings::Campaign.details[:hero_html_variant_name][:placeholder] %>
        </div>

        <div class="crayons-field crayons-field--checkbox">
          <%= f.check_box :articles_require_approval, checked: Settings::Campaign.articles_require_approval, class: "crayons-checkbox" %>
          <%= admin_config_label :articles_require_approval %>
          <%= admin_config_description Constants::Settings::Campaign.details[:articles_require_approval][:description] %>
        </div>

        <div class="crayons-field crayons-field--checkbox">
          <%= f.check_box :sidebar_enabled, checked: Settings::Campaign.sidebar_enabled, class: "crayons-checkbox" %>
          <%= admin_config_label :sidebar_enabled %>
          <%= admin_config_description Constants::Settings::Campaign.details[:sidebar_enabled][:description] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :sidebar_image %>
          <%= admin_config_description Constants::Settings::Campaign.details[:sidebar_image][:description] %>
          <% if Settings::Campaign.sidebar_image.present? %>
            <div class="flex flex-wrap flex-row -mx-4 mt-2">
              <div class="w-100 max-w-100 px-4">
                <img alt="Campaign sidebar image" class="max-w-100 h-auto" src="<%= Settings::Campaign.sidebar_image %>" />
              </div>
            </div>
          <% end %>
          <%= f.text_field :sidebar_image,
                           class: "crayons-textfield",
                           value: Settings::Campaign.sidebar_image,
                           placeholder: Constants::Settings::Campaign.details[:sidebar_image][:placeholder] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :url, "Campaign URL" %>
          <%= admin_config_description Constants::Settings::Campaign.details[:url][:description] %>
          <%= f.text_field :url,
                           class: "crayons-textfield",
                           value: Settings::Campaign.url,
                           placeholder: Constants::Settings::Campaign.details[:url][:placeholder] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :featured_tags %>
          <%= admin_config_description Constants::Settings::Campaign.details[:featured_tags][:description] %>
          <%= f.text_field :featured_tags,
                           class: "crayons-textfield",
                           value: Settings::Campaign.featured_tags.join(","),
                           placeholder: Constants::Settings::Campaign.details[:featured_tags][:placeholder] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :call_to_action, "Campaign Call to Action" %>
          <%= admin_config_description Constants::Settings::Campaign.details[:call_to_action][:description] %>
          <%= f.text_field :call_to_action,
                           class: "crayons-textfield",
                           value: Settings::Campaign.call_to_action,
                           placeholder: Constants::Settings::Campaign.details[:call_to_action][:placeholder] %>
        </div>

        <div class="crayons-field">
          <%= admin_config_label :articles_expiry_time, "Campaign article expiry time" %>
          <%= admin_config_description Constants::Settings::Campaign.details[:articles_expiry_time][:description] %>
          <%= f.number_field :articles_expiry_time,
                             class: "crayons-textfield",
                             value: Settings::Campaign.articles_expiry_time,
                             placeholder: Constants::Settings::Campaign.details[:articles_expiry_time][:placeholder] %>
        </div>
      </fieldset>
      <%= render "update_setting_button", f: f %>
    </div>
  </details>
<% end %>
